/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMaterialQueryParamConverter.java
 * Created：		2016年9月20日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.repair.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.repair.AMaterial;
import com.thor.palmmall.spi.basic.SMaterial;

/**
 * @author wolv
 *
 */
public class AMaterialConverter implements Converter<SMaterial, AMaterial> {

  public static AMaterialConverter getInstance() {
    if (instance == null)
      instance = new AMaterialConverter();
    return instance;
  }

  private static AMaterialConverter instance;

  private AMaterialConverter() {
  }

  @Override
  public AMaterial convert(SMaterial source) {
    if (source == null)
      return null;

    AMaterial target = new AMaterial();
    target.setCode(source.getCode());
    target.setName(source.getName());
    target.setPrice(source.getPrice());
    target.setQty(source.getQty());
    target.setSpecification(source.getSpecification());
    target.setBrand(UCN.newInstance(source.getBrand()));
    target.setUuid(source.getUuid());

    return target;
  }

}
